<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>获取当前元素相对于document的偏移量</title>
</head>
<style>
#wrap {
	width: 100px;
	height: 100px;
	background-color: #f00;
	margin: 100px;
}
</style>
<body>
<ul id="wrap">
	
</ul>
<script>
const getOffset = el => {
    const {
        top,
        left
    } = el.getBoundingClientRect()
    const {
        scrollTop,
        scrollLeft
    } = document.body
    return {
        top: top + scrollTop,
        left: left + scrollLeft
    }
}
const wrap = document.querySelector('#wrap')
console.log(getOffset(wrap))
</script>	
</body>
</html>